local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script, CommonOHOH.files.BaseComponent());
local Mouse = game.Players.LocalPlayer:GetMouse()
local CallBackManager = CommonOHOH.load.CallBackManager();

--控制武器的输入
function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);

	self.player=_G.client.local_player
	self.lastAttackTime=os.clock()

    CallBackManager:AddRbxConnect(self,Mouse.Button1Down, function()
		self.player.TryAttackEvent:Action()
	end);
	
	CallBackManager:AddRbxConnect(self,self.player.TryAttackEvent, function(obj,s)
			self:TryAttack(s)
	end);
    
end;


--尝试一次攻击
function M.TryAttack(self,s)
	local s= s or 1
	if os.clock()-self.lastAttackTime>=self.parent:GetAttackCd()*s then
		self.parent:StartAttack()
		self.lastAttackTime=os.clock()
	 end
end

function M.dtor(self)
	M.super.dtor(self);
end;


return M

